﻿package mortal.game.view.copy.wine.view
{
    import Message.Public.*;
    import com.gengine.utils.*;
    import com.mui.controls.*;
    import extend.language.*;
    import flash.events.*;
    import flash.utils.*;
    import mortal.common.*;
    import mortal.common.global.*;
    import mortal.component.window.*;
    import mortal.game.cache.*;
    import mortal.game.manager.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;
    import mortal.game.view.copy.wine.util.*;

    public class DonateFundsTipWin extends SmallWindow
    {
        private var _radio1:GRadioButton;
        private var _radio2:GRadioButton;
        private var _donateBtn:GButton;
        private var _cancelBtn:GButton;
        private var _checkDetailLink:GTextFiled;
        private var _currSelDonate:int;
        private static var _instance:DonateFundsTipWin;

        public function DonateFundsTipWin()
        {
            super(LayerManager.topLayer);
            if (_instance)
            {
                throw new Error("DonateFundsTipWin 单例");
            }
            setSize(253, 215 - 20);
            title = Language.getString(40978);
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            _isAddClolseButton = false;
            super.createDisposedChildrenImpl();
            var _loc_1:* = GlobalStyle.textFormatHuang2;
            _loc_1.size = 14;
            this.pushUIToDisposeVec(UIFactory.gTextField(Language.getString(40979), 60, 54 - 15, 170, 25, this, _loc_1));
            this.pushUIToDisposeVec(UIFactory.gTextField(Language.getString(40980), 60 - 30, 54 + 59, 210, 25, this, GlobalStyle.textFormatLv));
            this._radio1 = UIFactory.radioButton("50", 48 + 4, 81 - 3, 47, 25, this);
            this._radio2 = UIFactory.radioButton("100", 135 + 4, 81 - 3, 47, 25, this);
            this.pushUIToDisposeVec(UIFactory.gBitmap(ImagesConst.Yuanbao, 94, 81 - 3, this));
            this.pushUIToDisposeVec(UIFactory.gBitmap(ImagesConst.Yuanbao, 186, 81 - 3, this));
            this._radio1.groupName = "DonateRadioGroup";
            this._radio2.groupName = "DonateRadioGroup";
            this._radio1.configEventListener(Event.CHANGE, this.radioBtnChange);
            this._radio2.configEventListener(Event.CHANGE, this.radioBtnChange);
            this._radio1.selected = true;
            this._donateBtn = UIFactory.gButton(Language.getString(40981), 59, 162 + 6 - 20, 61, 27, this);
            this._cancelBtn = UIFactory.gButton(Language.getString(40982), 136 + 2, 162 + 6 - 20, 61, 27, this);
            this._donateBtn.configEventListener(MouseEvent.CLICK, this.onDonateHandler);
            this._cancelBtn.configEventListener(MouseEvent.CLICK, this.onCancelHandler);
            this._checkDetailLink = UIFactory.gTextField("", 59 + 28, 181, 157, 20, this, GlobalStyle.textFormatLv);
            this._checkDetailLink.htmlText = HTMLUtil.addLink(Language.getString(40983), GlobalStyle.colorLv);
            this._checkDetailLink.configEventListener(TextEvent.LINK, this.onLinkHandler);
            this._checkDetailLink.configEventListener(MouseEvent.MOUSE_OVER, this.onOverHandler);
            this._checkDetailLink.configEventListener(MouseEvent.MOUSE_OUT, this.onOutHandler);
            return;
        }// end function

        override protected function configParams() : void
        {
            super.configParams();
            paddingBottom = 61 - 5;
            paddingLeft = 7;
            paddingRight = 7;
            return;
        }// end function

        private function onLinkHandler(event:TextEvent) : void
        {
            WinePartyDonateRankWin.instance.show();
            return;
        }// end function

        private function onOverHandler(event:MouseEvent) : void
        {
            CursorManager.showCursor(CursorManager.BUTTON);
            return;
        }// end function

        private function onOutHandler(event:MouseEvent) : void
        {
            CursorManager.hideFromButton();
            return;
        }// end function

        private function radioBtnChange(event:Event) : void
        {
            if (this._radio1.selected)
            {
                this._currSelDonate = 50;
            }
            if (this._radio2.selected)
            {
                this._currSelDonate = 100;
            }
            return;
        }// end function

        private function onDonateHandler(event:MouseEvent) : void
        {
            var _loc_2:int = 0;
            if (this._radio1.selected)
            {
                _loc_2 = 50;
            }
            else
            {
                _loc_2 = 100;
            }
            if (Cache.instance.role.money.gold < _loc_2)
            {
                MsgManager.showRollTipsMsg(Language.getString(40984));
                return;
            }
            if (Cache.instance.guild.selfGuildInfo.baseInfo.money >= WinePartyConst.Wine_Donate_MaxValue)
            {
                MsgManager.showRollTipsMsg(Language.getString(40985));
                return;
            }
            var _loc_3:* = new Dictionary();
            _loc_3[EPriceUnit._EPriceUnitGold] = _loc_2;
            var _loc_4:* = new SPlayerItem();
            GameProxy.guild.donateResource(_loc_4, _loc_3);
            this.hide();
            return;
        }// end function

        private function onCancelHandler(event:MouseEvent) : void
        {
            this.hide();
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl();
            this._donateBtn.dispose();
            this._cancelBtn.dispose();
            this._checkDetailLink.dispose();
            this._radio1.dispose();
            this._radio2.dispose();
            this._donateBtn = null;
            this._cancelBtn = null;
            this._checkDetailLink = null;
            this._radio1 = null;
            this._radio2 = null;
            this._currSelDonate = 0;
            return;
        }// end function

        public static function get instance() : DonateFundsTipWin
        {
            if (_instance == null)
            {
                _instance = new DonateFundsTipWin;
            }
            return _instance;
        }// end function

    }
}
